package ar.edu.itba.it.paw.web.converter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import ar.edu.itba.it.paw.domain.Product;
import ar.edu.itba.it.paw.services.ProductServices;

@Component
public class ProductConverter implements Converter<String,Product> {

	ProductServices service;
	
	@Autowired
	public ProductConverter( ProductServices service){
		this.service = service;
	}

	@Override
	public Product convert(String source) {
		return service.getProduct(Integer.valueOf(source));
	}
	
}
